package com.example.producer.controller;

import com.example.producer.enums.QueueType;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description
 * @author shiguorang
 * @date 2023/6/28 19:33:15
 * @version 1.0
 */
@RestController
@RequestMapping("RabbitSender")
public class RabbitSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    /**
     * 发送消息
     */
    @GetMapping("sendMsg")
    public void sendMsg(@RequestParam("msg") String msg) {
        this.rabbitTemplate.convertAndSend(QueueType.MY_QUEUE.getValue(), msg);
    }
}
